package com.fdl.service.security.impl;

import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.springframework.dao.DataAccessException;

import com.fdl.dao.model.security.User;

/**
 * 
 * @description
 * @project: hb-intra
 * @Date:2010-8-4
 * @version 1.0
 * @Company: 33e9
 * @author zhangYong.huang
 */
public class UserDetailsServiceImpl implements UserDetailsService {
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException, DataAccessException {
		User user = null;
		if (username != null) {
			user = User.loadByUserID(username.trim());
		}

		if (user == null || !user.isEnabled()) {
			throw new UsernameNotFoundException("User not found");
		}

		return user;
	}
}
